import 'package:aio/aio.dart';
import 'package:flutter/material.dart';
import 'package:myapp/generated/app_strings.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({Key? key}) : super(key: key);

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  final _factoryController = TextEditingController();
  final _usernameController = TextEditingController();
  final _passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Stack(
          children: [
            SingleChildScrollView(
              child: Padding(
                padding: const EdgeInsets.symmetric(horizontal: 24.0),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const SizedBox(height: 50),
                    // Logo
                    Image.asset(
                      'assets/images/bwg_logo.png',
                      height: 120,
                    ),
                    const SizedBox(height: 40),
                    // BWG亮鲸 text
                    Text(
                      AppStrings.of(context).appTitle,
                      style: const TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.bold,
                        color: Color(0xFF1a237e),
                      ),
                    ),
                    const SizedBox(height: 60),
                    // Factory name input
                    TextField(
                      controller: _factoryController,
                      decoration: InputDecoration(
                        prefixIcon: const Icon(Icons.business, color: Color(0xFF1a237e)),
                        hintText: AppStrings.of(context).factoryName,
                        hintStyle: TextStyle(color: Colors.grey[400]),
                        enabledBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Colors.grey),
                        ),
                        focusedBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Color(0xFF1a237e)),
                        ),
                      ),
                    ),
                    const SizedBox(height: 20),
                    // Username input
                    TextField(
                      controller: _usernameController,
                      decoration: InputDecoration(
                        prefixIcon: const Icon(Icons.person_outline, color: Color(0xFF1a237e)),
                        hintText: AppStrings.of(context).username,
                        hintStyle: TextStyle(color: Colors.grey[400]),
                        enabledBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Colors.grey),
                        ),
                        focusedBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Color(0xFF1a237e)),
                        ),
                      ),
                    ),
                    const SizedBox(height: 20),
                    // Password input
                    TextField(
                      controller: _passwordController,
                      obscureText: true,
                      decoration: InputDecoration(
                        prefixIcon: const Icon(Icons.lock_outline, color: Color(0xFF1a237e)),
                        hintText: AppStrings.of(context).password,
                        hintStyle: TextStyle(color: Colors.grey[400]),
                        enabledBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Colors.grey),
                        ),
                        focusedBorder: const UnderlineInputBorder(
                          borderSide: BorderSide(color: Color(0xFF1a237e)),
                        ),
                      ),
                    ),
                    const SizedBox(height: 40),
                    // Login button
                    SizedBox(
                      width: double.infinity,
                      height: 50,
                      child: ElevatedButton(
                        onPressed: () {
                          // TODO: Implement login logic
                        },
                        style: ElevatedButton.styleFrom(
                          backgroundColor: const Color(0xFF1a237e),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(25),
                          ),
                        ),
                        child: Text(
                          AppStrings.of(context).login,
                          style: const TextStyle(
                            fontSize: 18,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Positioned(
              left: 16,
              top: 16,
              child: Material(
                color: Colors.transparent,
                child: IconButton(
                  icon: const Icon(Icons.arrow_back, color: Color(0xFF1a237e)),
                  onPressed: () {
                    LibRouteHelper.pop(context);
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    _factoryController.dispose();
    _usernameController.dispose();
    _passwordController.dispose();
    super.dispose();
  }
} 